import React, { useEffect } from "react"
import { Link } from "react-router"
import { useAppSelector } from "../../../redux"

const Login:React.FC=()=>{
    const isLogin = useAppSelector(state=>state.userInfo.isLogin)

    const show = ()=>{
        if(!isLogin){
            return (
                <Link to="/login"><span>登录</span><span>|</span><span>注册</span></Link>
            )
        }else{
            return (
                <Link to="/userPage"><span>已登录</span></Link>
            )
        }
    }
    
    useEffect(()=>{
        show()
    },[isLogin])
    
    
    return (
        <>
            <div className="w-20 h-10 inline-block z-10 float-right mx-3.5 my-3.5 py-2 ">
                {show()}
            </div>
        </>
    );
}
export default Login